package com.timothy.gfund.activity;

import java.util.ArrayList;
import java.util.List;
import com.timothy.junk.R;
import com.timothy.junk.adapter.RepoSettingAdaptor;
import com.timothy.junk.common.parse.RepoParser;
import com.timothy.gfund.bean.Repo;
import com.timothy.gfund.bean.RepoSetting;

import android.app.ListActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;

public class RepoSettingList extends ListActivity {
	public static final String LOG_TAG = "RepoList";

    Context mContext;
    SharedPreferences sp;
    
    List<Repo> repoList;
    List<RepoSetting> repoSettingList;
    RepoSettingAdaptor adaptor ;
    
    public void loadData(){
        repoSettingList = new ArrayList<RepoSetting>();
        repoList = RepoParser.getRepoList(mContext);
        for (Repo repo : repoList) {
        	RepoSetting sRepo = new RepoSetting(5.0);
        	sRepo.setIndex(repo.getIndex());
        	sRepo.setCode(repo.getCode());
        	sRepo.setName(repo.getName());
        	sRepo.setType(repo.getType());
        	repoSettingList.add(sRepo);
        }
    }
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.repo_setting_list);
        mContext = getApplicationContext();
        
        loadData();
        
        sp = this.getSharedPreferences("GFundApp",MODE_PRIVATE);
        adaptor = new RepoSettingAdaptor(mContext, repoSettingList,sp); 
        setListAdapter(adaptor);
    }

}
